<template>
  <div>
    <el-form ref="formItem" :rules="ruleValidate" :model="formItem" label-width="150px" @submit.native.prevent>
      <el-form-item label="用户ID：" v-if="formItem.uid">
        <el-input
          class="form-sty"
          disabled
          v-model="formItem.uid"
          placeholder="请输入编号"
          style="width: 80%"
        ></el-input>
      </el-form-item>
	  
	  
	  <el-form-item v-if="roles == 777 || roles == 10" label="用户类型：">
	    <el-radio-group v-model="formItem.customer_type" class="form-sty">
	<!--      <el-radio :label="2">教师</el-radio>
		  <el-radio :label="3">员工</el-radio> -->
		  <el-radio :label="4">代理商</el-radio>
	    </el-radio-group>
	  </el-form-item>
	  
	  <el-form-item v-if="roles == 1" label="用户类型：">
	    <el-radio-group v-model="formItem.customer_type" class="form-sty">
	      <el-radio :label="1">学员</el-radio>
	    <!--  <el-radio :label="2">教师</el-radio>
	  		  <el-radio :label="3">员工</el-radio>
	  		  <el-radio :label="4">代理商</el-radio> -->
	    </el-radio-group>
	  </el-form-item>
	  
	  
	  
      <el-form-item label="姓名：" >
        <el-input
          class="form-sty"
          v-model.trim="formItem.real_name"
          placeholder="请输入学员姓名"
          style="width: 80%"
        ></el-input>
      </el-form-item>
	  
	  <el-form-item label="代理商昵称：" v-if="formItem.customer_type == 4" >
	    <el-input
	      class="form-sty"
	      v-model.trim="formItem.mask_nickname"
	      placeholder="请输入代理商昵称"
	      style="width: 80%"
	    ></el-input>
	  </el-form-item>
	  
      <!-- <el-form-item label="联系手机(非必填)：" >
        <el-input class="form-sty" v-model="formItem.phone" placeholder="请输入联系手机" style="width: 80%"></el-input>
      </el-form-item> -->
	  
	  <el-form-item label="APP登录账号：" style="width: 200px;" >
	    <el-input class="form-sty" v-model="formItem.account" placeholder="请输入登入账号" style="width: 80%"></el-input>
	  </el-form-item>
	
	  
	  <!-- <el-form-item label="APP登录密码：" >
	    <el-input
	      class="form-sty"
	  
	      v-model="formItem.pwd"
	      placeholder="请输入登录密码,不填写默认密码123456"
	      style="width: 80%"
	    ></el-input>
	  </el-form-item> -->

	  <el-form-item label="所属学科：" v-if="formItem.customer_type == 2" style="width: 700px;">
	    <el-checkbox-group v-model="formItem.belong_subject">
	        <el-checkbox v-for="item,key in options" :label="item.id" :key="key">{{item.cate_name}}</el-checkbox>
	      </el-checkbox-group>
	  </el-form-item>
	  
	  
	  
	  
	  <el-form-item label="后台登录账号："  v-if="formItem.customer_type == 4">
	    <el-input class="form-sty" v-model="formItem.admin_account" placeholder="请输入后台登录账号" style="width: 80%"></el-input>
	  </el-form-item>
	  <el-form-item label="后台登录密码：" v-if="formItem.customer_type == 4">
	    <el-input
	      class="form-sty"
	 
	      v-model="formItem.admin_pwd"
	      placeholder="请输入后台登录密码"
	      style="width: 80%"
	    ></el-input>
	  </el-form-item>
	  
	  
	  <el-form-item  label="所属地址：" v-if="formItem.customer_type == 4 || formItem.customer_type == 1">
	    <el-cascader
	      :options="addresData"
	      v-model="formItem.address"
	      @change="handleChange"
	      style="width: 100%"
	    ></el-cascader>
	  </el-form-item>
	  
	  <!-- <el-form-item label="详细地址：" v-if="formItem.customer_type == 4 || formItem.customer_type == 1">
	    <el-input class="form-sty" v-model="formItem.detailed_address" placeholder="请输入详细地址" style="width: 80%"></el-input>
	  </el-form-item> -->
	  
	  
	  
<!-- 	  <el-form-item label="账号到期时间："  v-if="roles == 777 && formItem.customer_type == 1">
	    <el-date-picker v-model="formItem.account_end_time " type="date" placeholder="选择日期"></el-date-picker>
	  </el-form-item> -->
	  
	  <el-form-item label="学生性别：" v-if="formItem.customer_type == 1">
	    <el-radio-group v-model="formItem.gender" class="form-sty">
	      <el-radio :label="1">男生</el-radio>
	      <el-radio :label="2">女生</el-radio>
	    </el-radio-group>
	  </el-form-item>
	  
	  
	  <el-form-item label="代理商类型：" v-if="formItem.customer_type == 4">
	    <el-radio-group v-model="formItem.agent_type" class="form-sty">
	      <el-radio :label="1">分公司</el-radio>
	      <el-radio :label="2">服务中心</el-radio>
		<!--  <el-radio :label="3">C类型</el-radio>
		  <el-radio :label="4">D类型</el-radio> -->
	    </el-radio-group>
	  </el-form-item>
	  
	  <el-form-item label="是否享受卡密活动：" v-if="formItem.customer_type == 4">
	    <el-radio-group v-model="formItem.is_activity" class="form-sty">
	      <el-radio :label="1">享受</el-radio>
	      <el-radio :label="2">不享受</el-radio>
	  		<!--  <el-radio :label="3">C类型</el-radio>
	  		  <el-radio :label="4">D类型</el-radio> -->
	    </el-radio-group>
	  </el-form-item>
	  
	  

      <!-- <el-form-item label="账号状态：">
        <el-radio-group v-model="formItem.status" class="form-sty">
          <el-radio :label="1">开启</el-radio>
          <el-radio :label="0">禁用</el-radio>
        </el-radio-group>
      </el-form-item> -->
	
	  
	  <el-form-item label="所属年级：" v-if="formItem.customer_type == 1" >
	    <el-radio-group v-model="formItem.class" class="form-sty">
	      <el-radio :label="1" style="padding: 5px;">初一</el-radio>
	      <el-radio :label="2" style="padding: 5px;">初二</el-radio>
		  <el-radio :label="3" style="padding: 5px;">初三</el-radio>
		  <el-radio :label="7" style="padding: 5px;">初四</el-radio>
		  <el-radio :label="4" style="padding: 5px;">高一</el-radio>
		  <el-radio :label="5" style="padding: 5px;">高二</el-radio>
		  <el-radio :label="6" style="padding: 5px;">高三</el-radio>
	    </el-radio-group>
	  </el-form-item>
	  
	  <div v-if="formItem.customer_type == 1">
		  <el-form-item label="学业规划：" v-if="formItem.class == 1 || formItem.class == 2 || formItem.class == 3 || formItem.class == 7" >
		    <el-radio-group v-model="formItem.grade_plan" class="form-sty">
		  			<el-radio :label="2" style="padding: 5px;">六三制</el-radio>
		      <el-radio :label="1" style="padding: 5px;">五四制</el-radio>
		    </el-radio-group>
		  </el-form-item>
	  </div>
	 
	  
	  <el-form-item v-if="formItem.customer_type == 1" label="是否复读：">
	    <el-radio-group v-model="formItem.is_repeat" class="form-sty">
	      <el-radio :label="1" style="padding: 5px;">是</el-radio>
	      <el-radio :label="2" style="padding: 5px;">否</el-radio>
	    </el-radio-group>
	  </el-form-item>
	  
	  <el-form-item label="是否是测试号：" v-if="formItem.customer_type == 1 && admin_id == 85" >
	    <el-radio-group v-model="formItem.is_ceshi" class="form-sty">
	      <el-radio :label="1" style="padding: 5px;">是</el-radio>
	      <el-radio :label="2" style="padding: 5px;">不是</el-radio>
	    </el-radio-group>
	  </el-form-item>
	  
	  <el-form-item v-if="formItem.customer_type == 1" label="是否延期：">
	    <el-radio-group v-model="formItem.is_extend" class="form-sty">
	      <el-radio :label="1" style="padding: 5px;">正常</el-radio>
	      <el-radio :label="2" style="padding: 5px;">延期</el-radio>
	    </el-radio-group>
	  </el-form-item>
	  
	  <div class="item lang" v-if="formItem.customer_type == 1">
	    <el-form-item label="毕业年：" >
	      <div class="block">
	         <el-date-picker
	           v-model="formItem.graduate"
	           type="year"
	           placeholder="选择年">
	         </el-date-picker>
	       </div>
	    </el-form-item>
	  </div>
	  
	  <!-- <el-form-item label="学生年龄(非必填)：" v-if="formItem.customer_type == 1">
	    <el-input class="form-sty" v-model="formItem.age" placeholder="请输入用户年龄" style="width: 80%"></el-input>
	  </el-form-item> -->
	  
	  <el-form-item label="用户备注(非必填)：">
	    <el-input class="form-sty" v-model="formItem.mark" placeholder="请输入用户备注" style="width: 80%"></el-input>
	  </el-form-item>
	
	
		<el-form-item label="主科账号兑换科目：" v-if="formItem.customer_type == 1">
			<el-checkbox-group v-model="check_carmine_list" :max="zhuke_count" @change="zhukeChange" style="width: 460px;">
			   <el-checkbox v-for="(it, ix) in course_cate" :label="it.id">{{it.cate_name}}</el-checkbox>
			   <el-checkbox label="1111_1">科目待定</el-checkbox>
			   <el-checkbox label="1111_2">科目待定</el-checkbox>
			   <el-checkbox label="1111_3">科目待定</el-checkbox>
			   <el-checkbox label="1111_4">科目待定</el-checkbox>
			   <el-checkbox label="1111_5">科目待定</el-checkbox>
			</el-checkbox-group>
		</el-form-item>
		
		<div v-if="formItem.customer_type == 1 && activitygift > 0">
		  <el-form-item label="活动赠送科目：" >
			<div>可以选择{{activitygift}}科科目</div>
			<div v-if="huodong_number == 0">
				<el-checkbox-group v-if="activity_gift_type == 1" v-model="huodong_carmine_list" :max="activitygift" @change="huodongkeChange" style="width: 460px;">
				   <el-checkbox v-for="(it, ix) in course_cate" :label="it.id">{{it.cate_name}}</el-checkbox>
				   <el-checkbox label="3333_1">科目待定</el-checkbox>
				   <el-checkbox label="3333_2">科目待定</el-checkbox>
				   <el-checkbox label="3333_3">科目待定</el-checkbox>
				   <el-checkbox label="3333_4">科目待定</el-checkbox>
				   <el-checkbox label="3333_5">科目待定</el-checkbox>
				</el-checkbox-group>
				<el-checkbox-group v-if="activity_gift_type == 2" v-model="huodong_carmine_list" :max="activitygift" @change="huodongkeChange" style="width: 460px;">
				   <el-checkbox v-for="(it, ix) in course_cate" v-if="it.cate_type == 1" :label="it.id">{{it.cate_name}}</el-checkbox>
				   <el-checkbox label="3333_1">科目待定</el-checkbox>
				   <el-checkbox label="3333_2">科目待定</el-checkbox>
				   <el-checkbox label="3333_3">科目待定</el-checkbox>
				   <el-checkbox label="3333_4">科目待定</el-checkbox>
				   <el-checkbox label="3333_5">科目待定</el-checkbox>
				</el-checkbox-group>
				<el-checkbox-group v-if="activity_gift_type == 3" v-model="huodong_carmine_list" :max="activitygift" @change="huodongkeChange" style="width: 460px;">
				   <el-checkbox v-for="(it, ix) in course_cate" v-if="it.cate_type == 2" :label="it.id">{{it.cate_name}}</el-checkbox>
				   <el-checkbox label="3333_1">科目待定</el-checkbox>
				   <el-checkbox label="3333_2">科目待定</el-checkbox>
				   <el-checkbox label="3333_3">科目待定</el-checkbox>
				   <el-checkbox label="3333_4">科目待定</el-checkbox>
				   <el-checkbox label="3333_5">科目待定</el-checkbox>
				</el-checkbox-group>
			</div>
		  </el-form-item>
		</div>
	
		<el-form-item label="副科账号兑换科目：" v-if="formItem.customer_type == 1">
			<el-checkbox-group v-model="fu_check_carmine_list" style="width: 460px;" @change="fukeChange">
			   <el-checkbox v-for="(it, ix) in course_cate_fu" :label="it.id">{{it.cate_name}}</el-checkbox>
			   <el-checkbox label="2222_1">科目待定</el-checkbox>
			   <el-checkbox label="2222_2">科目待定</el-checkbox>
			   <el-checkbox label="2222_3">科目待定</el-checkbox>
			   <el-checkbox label="2222_4">科目待定</el-checkbox>
			   <el-checkbox label="2222_5">科目待定</el-checkbox>
			</el-checkbox-group>
		</el-form-item>
		
		
	 
	
	  <!-- <el-form-item label="选择所有学科：" v-if="formItem.customer_type == 1">
		<div v-if="check_carmine_list.length == 0">
			<el-button type="primary" @click="dialogVisible = true">选择卡密</el-button>
		</div>
	    <div v-else>
			<div v-for="item in check_carmine_list">{{item.carmine_text}}---选择的科目{{item.subject_name}}</div></br>
		</div>
	  </el-form-item>
	  
	  
	  <el-form-item label="选择副科学科：" v-if="formItem.customer_type == 1">
	  		<div v-if="fu_check_carmine_list.length == 0">
	  			<el-button type="primary" @click="dialogVisibleTwo = true">选择卡密</el-button>
	  		</div>
	    <div v-else>
	  			<div v-for="item in fu_check_carmine_list">{{item.carmine_text}}---选择的科目{{item.subject_name}}</div></br>
	  		</div>
	  </el-form-item> -->
	  
	  <!-- <div v-if="formItem.customer_type == 1 && activitygift > 0">
		  <el-form-item label="选择活动赠送的副科：" >
		  		<div v-if="huodong_number == 0">
		  			<el-button type="primary" @click="dialogVisiblezengsong = true">选择活动赠送副科</el-button>
		  		</div>
		  			<div v-else>
		  			<div v-for="item in formItem.huodong_carmine_list">选择的科目{{item}}</div></br>
		  		</div>
		  </el-form-item>
	  </div> -->
	  
	   
	  
	  <el-form-item label="是否激活听力：" v-if="formItem.customer_type == 1">
	    <el-radio-group v-model="formItem.is_hearing" class="form-sty">
	      <el-radio :label="1">激活</el-radio>
	      <el-radio :label="2">不激活</el-radio>
	    </el-radio-group>
		<div style="font-size: 12px;color: #8a8a8a;">可用次数：{{AdminUserInfo.hearing_count}}次</div>
	  </el-form-item> 
	  
	  <el-form-item label="是否激活阅读理解：" v-if="formItem.customer_type == 1">
	    <el-radio-group v-model="formItem.is_reading" class="form-sty">
	      <el-radio :label="1">激活</el-radio>
	      <el-radio :label="2">不激活</el-radio>
	    </el-radio-group>
		<div style="font-size: 12px;color: #8a8a8a;">可用次数：{{AdminUserInfo.reading_count}}次</div>
	  </el-form-item> 
	   
	  
    </el-form>

    <el-dialog
      :visible.sync="labelShow"
      scrollable
      title="请选择用户标签"
      :modal="false"
      :show-close="true"
      width="540px"
    >
      <userLabel
        v-if="labelShow"
        :only_get="true"
        :uid="formItem.uid"
        @close="labelClose"
        @activeData="activeData"
      ></userLabel>
    </el-dialog>
	
	
	
	<div>
		
		<el-dialog
		  title="所有学科卡密"
		  :visible.sync="dialogVisible"
		  width="35%"
		  >
		    <div style="height: 400px;">
				
				<div class="card-item"  v-for="(item, index) in zhu_carmine_list" :key="index" style="padding: 10px 0;">
				  <el-checkbox-group v-model="checkList" @change="checkChangeFn(item.id, index, item)">
				       <el-checkbox :label="item.id">
				        <span style="width: 100%;">{{item.carmine_text }}</span>
				       </el-checkbox>
				   </el-checkbox-group>
				   <div v-if="item.is_check">
					   <div style="margin-top: 10px;">
						   <el-radio-group v-model="zhu_carmine_list[index]['subject_name']">
						      <el-radio :label="it.cate_name" v-for="(it, ix) in course_cate" style="padding: 5px;">{{it.cate_name}}</el-radio>
						   </el-radio-group>
					    </div>
				   </div>
				</div>	
				
			</div>	  
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="dialogVisible = false">取 消</el-button>
		    <el-button type="primary" @click="allsubject">确 定</el-button>
		  </span>
		</el-dialog>
		
	</div>
	
	
	
	
	
	<div>
		<el-dialog
		  title="副科卡密"
		  :visible.sync="dialogVisibleTwo"
		  width="50%"
		  >
		    <div class="card-item"  v-for="(item, index) in fu_carmine_list" :key="index" style="padding: 10px 0;">
		      <el-checkbox-group v-model="checkList" @change="checkChangeFntwo(item.id, index, item)">
		           <el-checkbox :label="item.id">
		            <span style="width: 100%;">{{item.carmine_text }}</span>
		           </el-checkbox>
		       </el-checkbox-group>
			   <div v-if="item.is_check">
				   <div style="margin-top: 10px;">
					   <el-radio-group v-model="fu_carmine_list[index]['subject_name']" style="display: flex;flex-wrap: wrap;">
						   <div v-for="(it, ix) in course_cate">
							   <el-radio v-if="it.cate_type == 2" :label="it.cate_name" style="padding: 5px;">{{it.cate_name}}</el-radio>
							   <el-radio v-else disabled :label="it.cate_name" style="padding: 5px;">{{it.cate_name}}</el-radio>
						   </div>
					      
					   </el-radio-group>
				    </div>
			   </div>
		    </div>		  
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="dialogVisibleTwo = false">取 消</el-button>
		    <el-button type="primary" @click="fusubject">确 定</el-button>
		  </span>
		</el-dialog>
		
	</div>
	
	
	
	<div>
		<el-dialog
		  title="活动赠送副科"
		  :visible.sync="dialogVisiblezengsong"
		  width="50%"
		  >
		    
			
			<div style="text-align: center;font-size: 18px;margin-bottom: 10px;">可以选择{{activitygift}}科</div>
			<div v-if="activity_gift_type == 1">
				<el-checkbox-group v-model="zengsong_checkList" :max="activitygift">
					<el-checkbox v-for="(item, index) in course_cate"  :label="item.cate_name" key="item.id"></el-checkbox>
				</el-checkbox-group>	
			</div>
			
			<div v-if="activity_gift_type == 2">
				<el-checkbox-group v-model="zengsong_checkList" :max="activitygift">
					<el-checkbox v-for="(item, index) in course_cate" v-if="item.cate_type == 1" :label="item.cate_name" key="item.id"></el-checkbox>
				</el-checkbox-group>	
			</div>
			
			<div v-if="activity_gift_type == 3">
				<el-checkbox-group v-model="zengsong_checkList" :max="activitygift">
					<el-checkbox v-for="(item, index) in course_cate" v-if="item.cate_type == 2" :label="item.cate_name" key="item.id"></el-checkbox>
				</el-checkbox-group>	
			</div>
				
			
				  
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="dialogVisiblezengsong = false">取 消</el-button>
		    <el-button type="primary" @click="hudongsubject">确 定</el-button>
		  </span>
		</el-dialog>
		
	</div>
	

  </div>
</template>

<script>
import userLabel from '@/components/userLabel';
import { cityList } from '@/api/app';
import { userLabelAddApi,getAgentAllCarmineApi,getAdminUserInfo } from '@/api/user';
import { getcoursecatelist,carmineActivity } from '@/api/product';
export default {
  name: 'userEdit',
  components: { userLabel },
  props: {
    // modals: {
    //   default: false,
    //   type: Boolean,
    // },
    userData: {
      type: Object,
      default: () => {},
    },
  },
  watch: {},
  data() {
    return {
		
		zhuke_count:0,  //代理商主科的卡密数量
		
		
		
		admin_id:0,
		
		activity_gift_type:3,  //活动赠送科目类型  1是全部  2是只主科  3是只副科
		
		activitygift:0,  //活动赠送数量
		huodong_number:0,  //选择活动赠送科目的数量
		zengsong_checkList: [],  //选择活动赠送的副科
		
		activity_list:[],  //卡密活动列表
		
		zong_zhu_carmine_list:[],
		zong_fu_carmine_list:[],
		zhu_carmine_list:[],
		fu_carmine_list:[],
		course_cate:[],
		course_cate_fu:[],
		
		check_carmine_list:[],  //添加学员所有学科选择
		fu_check_carmine_list:[],  //添加学员所有学科选择
		
		huodong_carmine_list:[],  //新的选中活动课程
		
		checkList:[],
		dialogVisible: false,
		dialogVisibleTwo:false,
		dialogVisiblezengsong:false,
		
	  options:[], //科目列表	
	  roles:0,  //管理员权限	
	  addresData: [],
	  addresDataTwo: [],
	  
      modals: false,
      labelShow: false,
      formItem: {
        uid: 0,
        real_name: '',
        mask_nickname: '',
        phone: '',
        birthday: '',
        card_id: '',
        addres: '',
        mark: '',
        pwd: '',
        true_pwd: '',
        level: '',
        group_id: '',
        label_id: [],
        spread_open: 0,
        is_promoter: 0,
        status: 1,
		user_identity: 1,  //用户身份  1是普通用户  2是付费学员
		account:'',  //账号
		customer_type:1,  //用户类型 1是学员  2是教师 3是员工  4是代理商
		belong_subject:[],  //教师 所属学科
		admin_account:'',  //后台登录账号
		admin_pwd:'',  //后台登录密码
		address:[],  //代理商省市区
		detailed_address:'',  //代理商详细地址
		gender:1, //性别
		agent_type:1, //代理商类型
		is_activity:1, //是否享受卡密活动
		is_ceshi:2, //是否是测试号 1是  2不是
		graduate:'', //毕业年限
		is_hearing:2, //是否激活听力
		is_reading:2, //是否激活阅读理解
		age:0,  //学生年龄
		class:1, //所属班级
		grade_plan:2, //是五四制  2是六三制
		is_repeat:2, //是复读  1是复读 2是否
		is_extend:1, //是否延期  1是正常 2是延期
		account_end_time:'',  //学员到期时间
		
		check_carmine_list:[],  //主课选择
		fu_check_carmine_list:[],  //用户副科选择
		huodong_carmine_list:[],  //活动副科选择
      },
      groupInfo: [],
      labelInfo: [],
      levelInfo: [],

      infoData: {
        groupInfo: [],
        labelInfo: [],
        levelInfo: [],

      },
      ruleValidate: {
        real_name: [{ required: true, message: ' ', trigger: 'blur' }],
        account: [{ required: true, message: ' ', trigger: 'blur' }],
        admin_account: [{ required: true, message: ' ', trigger: 'blur' }],
        phone: [{ required: true, message: ' ', trigger: 'blur' }],
        pwd: [{ required: true, message: ' ', trigger: 'blur' }],
        true_pwd: [{ required: true, message: ' ', trigger: 'blur' }],
      },
      dataLabel: [],
	  
	  AdminUserInfo:{},
    };
  },
  created() {
	   
    this.getCityList();
	this.getAgentAllCarmineApi();
	this.getAdminUserInfo();
	
	this.check_carmine_list = [];
	this.zhu_carmine_list = this.zong_zhu_carmine_list
	this.fu_carmine_list = this.zong_fu_carmine_list	 
  },
  mounted() {
    this.$set(this.infoData, 'groupInfo', this.userData.groupInfo);
    this.$set(this.infoData, 'levelInfo', this.userData.levelInfo);
    this.$set(this.infoData, 'labelInfo', this.userData.labelInfo);
  


    let arr = Object.keys(this.formItem);
    if (this.userData.userInfo) {
      arr.map((i) => {
        this.formItem[i] = this.userData.userInfo[i];
      });
      if (!this.formItem.birthday) this.formItem.birthday = '';
      if (this.formItem.label_id.length) {
        this.dataLabel = this.formItem.label_id;
      }
    } else {
      this.reset();
    }
	
	this.getcoursecatelist();
	this.carmineActivity();

    // this.formItem = this.userData.userInfo;
  },
  methods: {
	//选中主科时候的选择时间
	zhukeChange(e){
		this.formItem.check_carmine_list = e
		this.activitygift = 0;
		this.activity_gift_type = 3;
		this.huodong_carmine_list = [];
		this.formItem.huodong_carmine_list = [];
		var zhuCount = 0;
		for(var i=0;i<e.length;i++){
			if(e[i] == 4 || e[i] == 5 || e[i] == 6 || e[i] == 7 || e[i] == 8 || e[i] == 9 || e[i] == '1111_1' || e[i] == '1111_2' || e[i] == '1111_3' || e[i] == '1111_4' || e[i] == '1111_5'){
				zhuCount++
			}
		}
		if(this.activity_list.length > 0 && zhuCount > 0){
			for(var i = 0;i<this.activity_list.length;i++){
				if(zhuCount == this.activity_list[i].major_number){
					console.log(this.activity_list[i].major_number);
					this.activitygift = this.activity_list[i].minor_number;
					this.activity_gift_type = this.activity_list[i].gift_type;
				}
			}
		}else{
			this.activitygift = 0;
		}
	},  
	//副科选择
	fukeChange(e){
		this.formItem.fu_check_carmine_list = e
	},
	//活动科目选择
	huodongkeChange(e){
		this.formItem.huodong_carmine_list = e
	},
	
	getAdminUserInfo(){
		getAdminUserInfo().then((res) => {
			
			this.AdminUserInfo = res.data.info
		  
		});
	},
	
	//活动副科提交
	hudongsubject(){
		console.log(this.zengsong_checkList);
		if(this.zengsong_checkList.length > 0){
			this.huodong_number = this.zengsong_checkList.length
			this.formItem.huodong_carmine_list = this.zengsong_checkList;
		}
		
		this.dialogVisiblezengsong = false;
	},
	
	//副科提交
	fusubject(){
		for(var i=0;i<this.fu_carmine_list.length;i++){
			if(this.fu_carmine_list[i]['is_check']){
				//判断是否选择学科
				if(this.fu_carmine_list[i]['subject_name'] == ''){
					this.$message.error('请选择具体科目');
					return false;
				}
				var base = {
					'carmine_text':this.fu_carmine_list[i]['carmine_text'],
					'id':this.fu_carmine_list[i]['id'],
					'subject_name':this.fu_carmine_list[i]['subject_name'],
				}
				this.fu_check_carmine_list.push(base)
			}
		}
		this.formItem.fu_check_carmine_list = this.fu_check_carmine_list
		this.dialogVisibleTwo = false;
	},
	
	//所有学科提交
	allsubject(){
		for(var i=0;i<this.zhu_carmine_list.length;i++){
			if(this.zhu_carmine_list[i]['is_check']){
				//判断是否选择学科
				if(this.zhu_carmine_list[i]['subject_name'] == ''){
					this.$message.error('请选择具体科目');
					return false;
				}
				var base = {
					'carmine_text':this.zhu_carmine_list[i]['carmine_text'],
					'id':this.zhu_carmine_list[i]['id'],
					'subject_name':this.zhu_carmine_list[i]['subject_name']
				}
				this.check_carmine_list.push(base)
			}
		}
		this.formItem.check_carmine_list = this.check_carmine_list
		
		console.log('777777777777777777777');
		console.log(this.formItem.check_carmine_list);
		let zhuCount = 0
		for(var i=0;i<this.formItem.check_carmine_list.length;i++){
			var subject_name = this.formItem.check_carmine_list[i].subject_name;
			if(subject_name == '高中语文' || subject_name == '高中数学' || subject_name == '高中英语' || subject_name == '初中语文' || subject_name == '初中数学' || subject_name == '初中英语'){
				console.log('进入这里');
				zhuCount++
			}
		}
		console.log(zhuCount);
		console.log('777777777777777777777');
		
		//判断有没有活动  activity_list
		
		console.log(zhuCount);
		console.log(this.activity_list);
		
		if(this.activity_list.length > 0 && zhuCount > 0){
			console.log('baga11111111');
			for(var i = 0;i<this.activity_list.length;i++){
				console.log('baga');
				if(zhuCount == this.activity_list[i].major_number){
					console.log('进入赠送');
					console.log(this.activity_list[i].major_number);
					this.activitygift = this.activity_list[i].minor_number;
					this.activity_gift_type = this.activity_list[i].gift_type;
				}
			}
		}
		
		console.log('赠送数量');
		console.log(this.activitygift);
		
		this.dialogVisible = false;
	},
	
	//选择多选框
	checkChangeFn(id,index,item){
		this.zhu_carmine_list[index]['is_check'] = !this.zhu_carmine_list[index]['is_check'];
	},  
	
	checkChangeFntwo(id,index,item){
		this.fu_carmine_list[index]['is_check'] = !this.fu_carmine_list[index]['is_check'];
	},
	  
	
	
	
	// 选择地址
	handleChange(value, selectedData) {
	  this.formItem.address = selectedData.map((o) => o.value);
	},  
	  
	
	getCityList() {
		cityList().then((res) => {
		  this.addresData = res.data.data;
		  this.addresDataTwo = res.data.data_two;
		  this.roles = res.data.roles
		  this.admin_id = res.data.admin_id
		  if(this.roles == 1){
			  this.formItem.customer_type = 1
		  }else{
			  this.formItem.customer_type = 4
		  }
		  
		});
	},
	
	//获取当前代理商所有的卡密
	getAgentAllCarmineApi(){
		var that = this
		getAgentAllCarmineApi()
		  .then((res) => {
			  that.zhu_carmine_list = res.data.zhu_carmine_list
			  that.fu_carmine_list = res.data.fu_carmine_list
			  that.course_cate = res.data.course_cate
			  that.course_cate_fu = res.data.course_cate_fu
			  that.zong_zhu_carmine_list = res.data.zhu_carmine_list
			  that.zong_fu_carmine_list = res.data.fu_carmine_list
			that.zhuke_count = res.data.zhuke_count	
		  })
		  .catch((res) => {
		    this.$message.error(res.msg);
		  });
	},
	
	carmineActivity(){
		var that = this
		carmineActivity()
		  .then((res) => {
			
				that.activity_list = res.data.list
		  })
		  .catch((res) => {
		    this.$message.error(res.msg);
		  });
	},
	
	// 获取科目分类；
	getcoursecatelist() {
	  getcoursecatelist()
	    .then((res) => {
			this.options = res.data
	      // this.treeSelect = res.data;
	    })
	    .catch((res) => {
	      this.$message.error(res.msg);
	    });
	},  
	  
    addLabel() {
      this.$modalForm(userLabelAddApi(0)).then(() => {});
    },
    changeModal(status) {
      if (!status) {
        this.cancel();
        this.reset();
      }
    },
    openLabel(row) {
      this.labelShow = true;
      this.$refs.userLabel.userLabel(JSON.parse(JSON.stringify(this.infoData.labelInfo)));
    },
    cancel() {},
    activeData(dataLabel) {
      this.labelShow = false;
      this.dataLabel = dataLabel;
    },
    // 标签弹窗关闭
    labelClose() {
      this.labelShow = false;
    },
    closeLabel(label) {
      let index = this.dataLabel.indexOf(this.dataLabel.filter((d) => d.id == label.id)[0]);
      this.dataLabel.splice(index, 1);
    },
    reset() {
      this.formItem = {
        uid: '',
        real_name: '',
        mask_nickname: '',
        phone: '',
        birthday: '',
        card_id: '',
        addres: '',
        mark: '',
        pwd: '',
        true_pwd: '',
        level: '',
        group_id: '',
        label_id: [],
        spread_open: 0,
        is_promoter: 0,
        status: 1,
		gender:1,
		agent_type:1,
		is_activity:1,
		is_ceshi:2,
		graduate:'',
		is_hearing:2,
		is_reading:2,
		age:'',  //年龄
		class:1,
		grade_plan:2, //是五四制  2是六三制
		is_repeat:2, //是复读  1是复读 2是否
		is_extend:1, //是否延期  1是正常 2是延期
		user_identity:1,
		account:'',
		customer_type:1,
		belong_subject:[],
		admin_account:'',
		admin_pwd:'',
		
      };
    },
  },
};
</script>

<style lang="stylus" scoped>
.labelInput {
  border: 1px solid #dcdee2;
  width: 400px;
  padding: 0 15px;
  border-radius: 5px;
  min-height: 30px;
  cursor: pointer;
  font-size: 12px;

  .span {
    color: #c5c8ce;
  }

  .iconxiayi {
    font-size: 12px;
  }
}

.ivu-form-item {
  margin-bottom: 10px;
}

.form-sty {
  width: 400px !important;
}

.addfont {
  display: inline-block;
  font-size: 12px;
  font-weight: 400;
  color: var(--prev-color-primary);
  margin-left: 14px;
  cursor: pointer;
  margin-left: 10px;
}

.ivu-icon-ios-arrow-down {
  font-size: 14px;
}

.tip {
  color: #bbb;
  font-size: 12px;
  line-height: 12px;
}
</style>
